for i in range(int(input())):
n=int(input())
a=list(map(int,input().split()))+[0]
count=0
for i in range(1,n-1):
if a[i-1]<a[i]>a[i+1]:
a[i+1]=max(a[i],a[i+2])
count+=1
print(count)
print(*a[:-1])
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define read freopen("0_input.txt","r",stdin)
#define write freopen("0_output.txt","w",stdout)
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
#define lld long long int
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define mXs 1e6
#define test long long int ct;cin >> ct;while (ct--)
const double pi = acos(-1.0);
void solve(){
lld n,i,j,ans=0,minn,maxx;
cin>>n;
lld ara[n];
for(i=0;i<n;i++){
cin>>ara[i];
}
for(i=1;i<n-1;i++){
if(ara[i]>ara[i-1] && ara[i]>ara[i+1]){
if(i + 2 < n)
ara[i + 1] = max(ara[i], ara[i + 2]);
else
ara[i + 1] = ara[i];
ans++;
}
}
cout<<ans<<endl;
for(i=0;i<n;i++){
cout<<ara[i]<<" ";
}
cout<<endl;
}
int main()
{
cin.tie(NULL);
//read;
//write;
ios_base::sync_with_stdio(false);
test{
solve();
}
return 0;
}
1399A - Remove Smallest | 208A - Dubstep |
1581A - CQXYM Count Permutations | 337A - Puzzles |
495A - Digital Counter | 796A - Buying A House |
67A - Partial Teacher | 116A - Tram |
1472B - Fair Division | 1281C - Cut and Paste |
141A - Amusing Joke | 112A - Petya and Strings |
677A - Vanya and Fence | 1621A - Stable Arrangement of Rooks |
472A - Design Tutorial Learn from Math | 1368A - C+= |
450A - Jzzhu and Children | 546A - Soldier and Bananas |
32B - Borze | 1651B - Prove Him Wrong |
381A - Sereja and Dima | 41A - Translation |
1559A - Mocha and Math | 832A - Sasha and Sticks |
292B - Network Topology | 1339A - Filling Diamonds |
910A - The Way to Home | 617A - Elephant |
48A - Rock-paper-scissors | 294A - Shaass and Oskols |